/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "COMMENT_IMAGE")
@NamedQueries({@NamedQuery(name = "CommentImage.findAll", query = "SELECT c FROM CommentImage c"), @NamedQuery(name = "CommentImage.findByRefidcomment", query = "SELECT c FROM CommentImage c WHERE c.commentImagePK.refidcomment = :refidcomment"), @NamedQuery(name = "CommentImage.findByRefidaccount", query = "SELECT c FROM CommentImage c WHERE c.commentImagePK.refidaccount = :refidaccount"), @NamedQuery(name = "CommentImage.findByRefidimage", query = "SELECT c FROM CommentImage c WHERE c.commentImagePK.refidimage = :refidimage")})
public class CommentImage implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentImagePK commentImagePK;
    @JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @JoinColumn(name = "REFIDCOMMENT", referencedColumnName = "IDCOMMENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Comment comment;
    @JoinColumn(name = "REFIDIMAGE", referencedColumnName = "IDIMAGE", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Image image;

    public CommentImage() {
    }

    public CommentImage(CommentImagePK commentImagePK) {
        this.commentImagePK = commentImagePK;
    }

    public CommentImage(int refidcomment, int refidaccount, int refidimage) {
        this.commentImagePK = new CommentImagePK(refidcomment, refidaccount, refidimage);
    }

    public CommentImagePK getCommentImagePK() {
        return commentImagePK;
    }

    public void setCommentImagePK(CommentImagePK commentImagePK) {
        this.commentImagePK = commentImagePK;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentImagePK != null ? commentImagePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommentImage)) {
            return false;
        }
        CommentImage other = (CommentImage) object;
        if ((this.commentImagePK == null && other.commentImagePK != null) || (this.commentImagePK != null && !this.commentImagePK.equals(other.commentImagePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.CommentImage[commentImagePK=" + commentImagePK + "]";
    }

}
